"""
人物模型
"""
from sqlalchemy import Column, String, Integer, Text, Enum
from sqlalchemy.dialects.mysql import JSON
import enum

from .base import BaseModel

class RoleType(enum.Enum):
    """角色类型枚举"""
    PROTAGONIST = "PROTAGONIST"  # 主角
    COLLEAGUE = "COLLEAGUE"      # 同事
    SUPERIOR = "SUPERIOR"        # 上级
    SUBORDINANT = "SUBORDINANT"  # 下级
    CLIENT = "CLIENT"            # 客户
    OTHER = "OTHER"              # 其他

class Gender(enum.Enum):
    """性别枚举"""
    MALE = "MALE"       # 男
    FEMALE = "FEMALE"   # 女
    OTHER = "OTHER"     # 其他

class Character(BaseModel):
    """人物表模型"""
    __tablename__ = 'characters'
    
    # 人物基本信息（最小化业务字段）
    name = Column(String(100), nullable=False, comment='姓名')
    role_type = Column(Enum(RoleType), nullable=False, comment='角色类型')
    gender = Column(Enum(Gender), nullable=True, comment='性别')
    age = Column(Integer, nullable=True, comment='年龄')
    position = Column(String(100), nullable=True, comment='职位')
    department = Column(String(100), nullable=True, comment='部门')
    
    # 人物画像信息（JSON格式，便于扩展）
    basic_info = Column(JSON, nullable=True, comment='基本信息JSON')
    personality_tags = Column(JSON, nullable=True, comment='性格标签JSON')
    background_info = Column(JSON, nullable=True, comment='背景信息JSON')
    relationship_data = Column(JSON, nullable=True, comment='关系数据JSON')
    
    # 扩展字段
    description = Column(Text, nullable=True, comment='人物描述和备注')
    tags = Column(JSON, nullable=True, comment='标签JSON')
    meta_data = Column(JSON, nullable=True, comment='扩展元数据JSON')
    
    def __repr__(self):
        return f"<Character(name='{self.name}', role_type='{self.role_type}')>"